package com.zrrd.yunchmall.order;

import com.alibaba.cloud.nacos.ConditionalOnNacosDiscoveryEnabled;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;

/**
 * @author Liangyaoyun
 */
@SuppressWarnings("all")
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@ComponentScan(value = {"com.zrrd.yunchmall"})
@MapperScan("com.zrrd.yunchmall.order.mapper")
public class OrderApp {

    //先在订单服务的容器里面注入一个RestTemplate的bean
    //RestTemplate是使用模版模式创建的一个能发起http链接的组件,它的http复杂的链接过程提供了封装,可以使用它方便的创建一个http的客户端
    //在当前的Spring容器内注入一个RestTemplate实例
    @Bean
    //启用负载均衡器
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
    public static void main(String[] args) {
        SpringApplication.run(OrderApp.class,args);
    }
}
